package org.jrfe.gfx.g2d.text;

import org.jrfe.gfx.g2d.text.Font.CharData;
import org.lwjgl.opengl.GL11;

public class StaticText extends Text {
	
	protected int listId;
	protected String text;
	
	public StaticText(String text,Font font){
		super(TextType.STATIC, font);
		this.text = text;
	
		listId = GL11.glGenLists(1);
		
		GL11.glNewList(listId, GL11.GL_COMPILE);
		
		char[] cs = getText().toCharArray();

		CharData curent;
		for (int i = 0; i < cs.length; i++) {
			curent = getFont().getCharArray()[cs[i]];
			GL11.glTranslatef(curent.xExtend, 0, 0);
			GL11.glCallList(curent.listId);
			GL11.glTranslatef(curent.xExtend, 0, 0);
		}
		
		GL11.glEndList();
	
	}
	
	@Override
	public void destory() {
		GL11.glDeleteLists(listId, 1);
	}

	@Override
	public int getListId() {
		return listId;
	}

	@Override
	public String getText() {
		return text;
	}
	

}
